﻿@*
    TicketDesk - Attribution notice
    Contributor(s):

         Stephen Redd (stephen@reddnet.net, http://www.reddnet.net)

    This file is distributed under the terms of the Microsoft Public
    License (Ms-PL). See http://opensource.org/licenses/MS-PL
    for the complete terms of use.

    For any distribution that contains code from this file, this notice of
    attribution must remain intact, and a copy of the license must be
    provided to the recipient.
*@

@using System.Reflection
@using TicketDesk.PushNotifications
@model Dictionary<Type, TicketDesk.PushNotifications.Model.ApplicationPushNotificationSetting.PushNotificationDeliveryProviderSetting>

@foreach (var type in Model.Keys)
{
    var settings = Model[type];



    <div class="form-group">
        @Html.DescriptionFor(type, "col-md-4 col-sm-4 control-label", "label")
        <div class="col-md-8 col-sm-8">
            <label class="checkbox-inline" style="vertical-align: top;">
                @Html.CheckBox("IsEnabled", settings.IsEnabled, new { disabled = "disabled" })
                @Html.PromptFor(model => settings.IsEnabled);


            </label>

            <a class="btn btn-link" href="@Url.Action("ConfigureDeliveryProvider", "PushNotificationSettings", new {providerAssemblyQualifiedName = type.AssemblyQualifiedName})">
                <i class="fa fa-gear"> Configure</i>
            </a>

        </div>

    </div>
    if (settings.IsEnabled)
    {
        var provider = PushNotificationDeliveryManager.DeliveryProviders.FirstOrDefault(p => p.GetType().AssemblyQualifiedName == settings.ProviderAssemblyQualifiedName);
        if (provider != null)
        {
            PropertyInfo[] properties = provider.GetType().GetProperties(BindingFlags.Public);
            foreach (PropertyInfo property in properties)
            {
                <div>@property.GetValue(property, null)</div>
            }
        }
    }

}

